package com.woniuxy.yogaapp.mapper;

import com.woniuxy.yogaapp.dto.EvaluateDto;
import com.woniuxy.yogaapp.dto.UidDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.yogaapp.pojo.User;

public interface UserMapper {
	@Insert("insert into user(account,pass) values (#{account},#{pass})")
	int addUser(User user);

	@Select("select * from user where account=#{account}")
	User login(User user);

	@Update("update user set pass=#{pass} where account=#{account}")
	int updateNewPass(User user);

	@Select("select u.uid,snickname from student s inner join user u on s.uid=u.uid where  sid=#{sid}")
	public UidDto selectUidBysid(EvaluateDto evaluateDto);

	@Select("select u.uid from coach c inner join user u on c.uid=u.uid where  cid=#{cid}")
	public UidDto selectUidBycid(EvaluateDto evaluateDto);
     
	@Select("SELECT rname FROM  roles r,userroles ur,`user` u WHERE r.rid=ur.rid AND u.uid=ur.uid  AND u.account=#{account}")
	String findRoleByAccount(User user);
	
	
	/**
	 * 查询该用户的uid   根据account
	 */
	@Select("select uid from user where account=#{account}")
	public int findUidByAccount(User user);
}
